use serde::{Deserialize, Serialize};
use common::page::{BasePage, PageData};

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct CreateNetworkLog {
    pub u_id: i64,
    pub network_type: i32,
    pub source: Option<String>,
    pub stream: Option<String>,
    pub send: Option<i64>,
    pub receive: Option<i64>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct NetworkLogPage {
    pub page_data: Option<PageData>,
    pub u_id: Option<i64>,
    pub network_type: Option<i32>,
    pub source: Option<String>,
    pub stream: Option<String>,
    pub send: Option<i32>,
    pub receive: Option<i32>,
    pub create_time: Option<Vec<String>>,
}

impl BasePage for NetworkLogPage {
    fn get_page_data(&self) -> PageData {
        match self.page_data.clone() {
            None => {
                PageData{
                    page: 1,
                    page_size: 10,
                    sorter: None,
                }
            }
            Some(page_data) => {
                page_data
            }
        }
    }
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct NetworkConfPage {
    pub page_data: Option<PageData>,
    pub u_id: Option<i64>,
}

impl BasePage for NetworkConfPage {
    fn get_page_data(&self) -> PageData {
        match self.page_data.clone() {
            None => {
                PageData{
                    page: 1,
                    page_size: 10,
                    sorter: None,
                }
            }
            Some(page_data) => {
                page_data
            }
        }
    }
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct CreateNetworkConf {
    pub u_id: Option<i64>,
    pub conf_data: Option<String>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub enum NetworkConfType{
    Black,
    White,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct NetworkConfData {
    pub conf_type: Option<NetworkConfType>,
    pub domains: Vec<String>,
}